import { defineStore } from 'pinia'

export const useAuthStore = defineStore('auth', {
  state: () => ({ token: localStorage.getItem('token') || '' }),
  actions: {
    setToken(t) {
      this.token = t || ''
      if (t) localStorage.setItem('token', t); else localStorage.removeItem('token')
    },
    logout() { this.setToken('') }
  }
})


